<template>
  <el-row>
    <el-col>
      <el-card>
        <el-form ref="form" :model="wechatData" size="small" label-width="150px">
          <!--          <el-form-item label="微信APP支付AppID">-->
          <!--            <el-input v-model="wechatData.wx_native_app_appId" style="width: 370px" />-->
          <!--            <p style="color: red">-->
          <!--              微信开放平台审核通过的应用APPID（请登录open.weixin.qq.com查看，注意与公众号的APPID不同）-->
          <!--            </p>-->
          <!--          </el-form-item>-->
          <el-form-item label="商户id" prop="mchId">
            <el-input v-model="wechatData.mchId" style="width: 370px" />
          </el-form-item>
          <el-form-item label="商户密钥" prop="params.partnerKey">
            <el-input v-model="wechatData.params.partnerKey" style="width: 370px" />
          </el-form-item>
          <el-form-item label="domain" prop="params.domain">
            <el-input v-model="wechatData.params.domain" style="width: 370px" />
          </el-form-item>
          <el-form-item label="微信证书地址" prop="params.certPath" style="width: 370px">
            <el-input v-model="wechatData.params.certPath" style="width: 370px" />
            <!--            <el-upload-->
            <!--                v-model:file-list="fileList"-->
            <!--                class="upload-demo"-->
            <!--                action="https://run.mocky.io/v3/9d059bf9-4660-45f2-925d-ce80ad6c4d15"-->
            <!--                multiple-->
            <!--                :limit="3"-->
            <!--                :on-exceed="handleExceed"-->
            <!--            >-->
            <!--              <el-button type="primary">Click to upload</el-button>-->
            <!--              <template #tip>-->
            <!--                <div class="el-upload__tip">-->
            <!--                  jpg/png files with a size less than 500KB.-->
            <!--                </div>-->
            <!--              </template>-->
            <!--            </el-upload>-->
          </el-form-item>
          <el-form-item label="">
            <el-button type="primary" @click="doSubmit">提交</el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </el-col>
  </el-row>
</template>

<script setup lang="ts">
import { IHooksOptions } from '@/hooks/interface'
import { reactive, ref } from 'vue'
import { useCrud } from '@/hooks'
import { getWxListApi } from '@/api/wx/account'
import { ElMessage, ElMessageBox, UploadProps, UploadUserFile } from 'element-plus'
import { doSubmitApi } from '@/api/wx/payConfig'

const props = defineProps({
  data: {
    type: Object,
    required: true
  }
})
const wechatData = ref<any>({
  mchId: '',
  params: {
    partnerKey: '',
    domain: '',
    certPath: ''
  }
})
wechatData.value = props.data

const fileList = ref<UploadUserFile[]>([
  {
    name: 'element-plus-logo.svg',
    url: 'https://element-plus.org/images/element-plus-logo.svg'
  },
  {
    name: 'element-plus-logo2.svg',
    url: 'https://element-plus.org/images/element-plus-logo.svg'
  }
])

const handleExceed: UploadProps['onExceed'] = (files, uploadFiles) => {
  ElMessage.warning(`已到最大上传限度`)
}

function doSubmit() {
  doSubmitApi(wechatData.value).then(() => {
    ElMessage.success({
      message: '操作完成',
      duration: 500
    })
  })
}
</script>

<style></style>
